//
//  SNCompilePlanSectionHeaderView.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/29.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "SNFertilizerInformationController.h"
#import "SNPesticideInformationController.h"
#import "SNSummaryInfoViewController.h"
#import "UIImageView+TapGesture.h"
#import "SNCheckPlanSectionHeaderView.h"
#import "SNPlanListLabel.h"
#import "SNSeedViewController.h"
@interface SNCheckPlanSectionHeaderView()
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconImageViewHeightLayoutConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconImageViewWidthLayoutConstraint;

@property (weak, nonatomic) IBOutlet SNPlanListLabel *rightLabel;
@end
@implementation SNCheckPlanSectionHeaderView
- (void)configCellWithTitle:(NSString *)title imageName:(NSString *)imageName{
    
    self.iconImageView.image = [UIImage imageNamed:imageName];
    
    self.leftLabel.text = [NSString stringWithFormat:@"* %@",title];
    
    if([self.leftLabel.text containsString:@"概要信息"]){
        self.rightLabel.text = @"编辑";
        self.leftLabel.textColor = HexRGB(0x67B245);
        UIImage * image = self.iconImageView.image;
        self.iconImageViewWidthLayoutConstraint.constant = 20;
        self.iconImageViewHeightLayoutConstraint.constant = 20 * image.size.height / image.size.width;
    }else if ([self.leftLabel.text containsString:@"种子信息"]){
        self.rightLabel.text = @"编辑";
        self.leftLabel.textColor = HexRGB(0xF49E24);
        UIImage * image = self.iconImageView.image;
        self.iconImageViewWidthLayoutConstraint.constant = 20;
        self.iconImageViewHeightLayoutConstraint.constant = 20 * image.size.height / image.size.width;
    }else if ([self.leftLabel.text containsString:@"肥料信息"]){
        self.rightLabel.text = @"添加";
        self.leftLabel.text = [NSString stringWithFormat:@" * %@",title];
        self.leftLabel.textColor = HexRGB(0x04177A);
        UIImage * image = self.iconImageView.image;
        self.iconImageViewWidthLayoutConstraint.constant = 15;
        self.iconImageViewHeightLayoutConstraint.constant = 15 * image.size.height / image.size.width;
    }else if ([self.leftLabel.text containsString:@"农药信息"]){
        self.rightLabel.text = @"添加";
        self.leftLabel.textColor = HexRGB(0x078F91);
        self.leftLabel.text = [NSString stringWithFormat:@" %@",title];
        UIImage * image = self.iconImageView.image;
        self.iconImageViewWidthLayoutConstraint.constant = 20;
        self.iconImageViewHeightLayoutConstraint.constant = 20 * image.size.height / image.size.width;
    }
    [SNUtils specialLabelWithstring:self.leftLabel.text keyString:@"*" label:self.leftLabel color:HexRGB(0xFF5D04)];
    
    
    
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [SNUtils specialLabelWithstring:self.leftLabel.text keyString:@"*" label:self.leftLabel color:HexRGB(0xFF5D04)];
    
    
    UIImage * image = self.iconImageView.image;
    
    self.iconImageViewHeightLayoutConstraint.constant = 20 * image.size.height / image.size.width;
    @weakify_self
    self.rightLabel.sn_tapBlock = ^(){
        @strongify_self
        NSLog(@"%@ | %s",self.class,__func__);
        
        if([self.leftLabel.text containsString:@"概要信息"]){
            SNSummaryInfoViewController * vc = [SNSummaryInfoViewController new];
            
            [self.nav pushViewController:vc animated:YES];
        }else if ([self.leftLabel.text containsString:@"种子信息"]){
            SNSeedViewController * vc = [SNSeedViewController new];
            [self.nav pushViewController:vc animated:YES];
        }else if ([self.leftLabel.text containsString:@"肥料信息"]){
            SNFertilizerInformationController * vc = [SNFertilizerInformationController new];
            [self.nav pushViewController:vc animated:YES];
        }else if ([self.leftLabel.text containsString:@"农药信息"]){
            SNPesticideInformationController * vc = [SNPesticideInformationController new];
            [self.nav pushViewController:vc animated:YES];
        }
        
    };
}

@end

